Add seperate project file for misc. GPS data parser functions.
authoroliskoli <oliskoli>
Mon, 20 Aug 2007 22:02:26 +0000 (22:02 +0000)
committeroliskoli <oliskoli>
Mon, 20 Aug 2007 22:02:26 +0000 (22:02 +0000)
Remove duplicates from util.c.

util.c

diff --git a/util.c b/util.c
index 51b78cd3bd5268c7800427289a4bef6126b02898..3a24db4ff07cc6cf125750c5f77c1882aa894275 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1029,118 +1029,6 @@ double degrees2ddmm(double deg_val) {
        return (double) (deg * 100.0) + ((deg_val - deg) * 60.0);
 }
 
-/* 
- * Convert string 'str' into geodetic latitide & longitude values. The format
- * will be interpreted depending on 'grid' parameter.
- *
- * return value: number of characters efective parsed
- */
-
-int
-parse_coordinates(const char *str, int datum, const grid_type grid, 
-       double *latitude, double *longitude, const char *module)
-{
-       double lat, lon;
-       unsigned char lathemi, lonhemi;
-       int deg_lat, deg_lon, min_lat, min_lon;
-       char map[3];
-       int utmz;
-       double utme, utmn;
-       char utmc;
-       int valid, result, ct;
-       double lx, ly;
-       const char *format;
-       
-       valid = 1;
-       
-       switch(grid) {
-
-               case grid_lat_lon_ddd:
-                       format = "%c%lf %c%lf%n";
-                       ct = sscanf(str, format,
-                               &lathemi, &lat, &lonhemi, &lon, &result);
-                       valid = (ct == 4);
-                       break;
-
-               case grid_lat_lon_dmm:
-                       format = "%c%d %lf %c%d %lf%n";
-                       ct = sscanf(str, format,
-                               &lathemi, &deg_lat, &lat, &lonhemi, &deg_lon, &lon, &result);
-                       valid = (ct == 6);
-                       if (valid) {
-                               lat = (double)deg_lat + (lat / (double)60);
-                               lon = (double)deg_lon + (lon / (double)60);
-                       }
-                       break;
-               
-               case grid_lat_lon_dms:
-                       format = "%c%d %d %lf %c%d %d %lf%n";
-                       ct = sscanf(str, format,
-                               &lathemi, &deg_lat, &min_lat, &lat, &lonhemi, &deg_lon, &min_lon, &lon,
-                               &result);
-                       valid = (ct == 8);
-                       if (valid) {
-                               lat = (double)deg_lat + ((double)min_lat / (double)60) + (lat / (double)3600.0);
-                               lon = (double)deg_lon + ((double)min_lon / (double)60) + (lon / (double)3600.0);
-                       }
-                       break;
-               
-               case grid_bng:
-                       format = "%2s %lf %lf%n";
-                       ct = sscanf(str, format,
-                               map, &lx, &ly,
-                               &result);
-                       valid = (ct == 3);
-                       if (valid) {
-                               if (! GPS_Math_UKOSMap_To_WGS84_M(map, lx, ly, &lat, &lon))
-                                       fatal("%s: Unable to convert BNG coordinates (%s)!\n",
-                                               module, str);
-                       }
-                       datum = DATUM_WGS84;    /* fix */
-                       lathemi = lonhemi = '\0';
-                       break;
-                       
-               case grid_utm:
-                       format = "%d %c %lf %lf%n";
-                       ct = sscanf(str, format,
-                               &utmz, &utmc, &utme, &utmn,
-                               &result);
-                       valid = (ct == 4);
-                       if (valid) {
-                               if (! GPS_Math_UTM_EN_To_Known_Datum(&lat, &lon, utme, utmn, utmz, utmc, datum))
-                                       fatal("%s: Unable to convert UTM coordinates (%s)!\n",
-                                               module, str);
-                       }
-                       lathemi = lonhemi = '\0';
-                       break;
-                       
-               default:
-                       /* this should never happen in a release version */
-                       fatal("%s/util: Unknown grid in parse_coordinates (%d)!\n",
-                               module, (int)grid);
-       }
-       
-       if (! valid) {
-               warning("%s: sscanf error using format \"%s\"!\n", module, format);
-               warning("%s: parsing has stopped at parameter number %d.\n", module, ct);
-               fatal("%s: could not convert coordinates \"%s\"!\n", module, str);
-       }
-       
-       if (lathemi == 'S') lat = -lat;
-       if (lonhemi == 'W') lon = -lon;
-
-       if (datum != DATUM_WGS84) {
-               double alt;
-               GPS_Math_Known_Datum_To_WGS84_M(lat, lon, (double) 0.0,
-                       &lat, &lon, &alt, datum);
-       }
-
-       if (latitude) *latitude = lat;
-       if (longitude) *longitude = lon;
-               
-       return result;
-}
-
 /*
  * replace a single occurrence of "search" in  "s" with "replace".
  * Returns an allocated copy if substitution was made, otherwise returns NULL.